cmake_minimum_required(VERSION 2.8)
project(TEST)

set(GOOGLETEST C:/chenchang/dev/googletest)

include_directories(${GOOGLETEST}/googletest/include
    ${GOOGLETEST}/googlemock/include)

if (CMAKE_CL_64)
    set(ARCH X64)
else (CMAKE_CL_64)
    set(ARCH X86)
endif (CMAKE_CL_64)

link_libraries(${GOOGLETEST}/bld/${ARCH}/googlemock/$<$<CONFIG:Debug>:Debug>$<$<NOT:$<CONFIG:Debug>>:Release>/gmock.lib
    ${GOOGLETEST}/bld/${ARCH}/googlemock/$<$<CONFIG:Debug>:Debug>$<$<NOT:$<CONFIG:Debug>>:Release>/gmock_main.lib
    ${GOOGLETEST}/bld/${ARCH}/googlemock/gtest/$<$<CONFIG:Debug>:Debug>$<$<NOT:$<CONFIG:Debug>>:Release>/gtest.lib
    ${GOOGLETEST}/bld/${ARCH}/googlemock/gtest/$<$<CONFIG:Debug>:Debug>$<$<NOT:$<CONFIG:Debug>>:Release>/gtest_main.lib)

add_executable(main main.cpp)

add_custom_command(TARGET main POST_BUILD        # Adds a post-build event to MyTest
    COMMAND ${CMAKE_COMMAND} -E copy_if_different  # which executes "cmake - E copy_if_different..."
        "${GOOGLETEST}/bld/${ARCH}/googlemock/$<$<CONFIG:Debug>:Debug>$<$<NOT:$<CONFIG:Debug>>:Release>/gmock.dll"      # <--this is in-file
        $<TARGET_FILE_DIR:main>                 # <--this is out-file path
    COMMAND ${CMAKE_COMMAND} -E copy_if_different  # which executes "cmake - E copy_if_different..."
        "${GOOGLETEST}/bld/${ARCH}/googlemock/$<$<CONFIG:Debug>:Debug>$<$<NOT:$<CONFIG:Debug>>:Release>/gmock_main.dll"      # <--this is in-file
        $<TARGET_FILE_DIR:main>                 # <--this is out-file path
    COMMAND ${CMAKE_COMMAND} -E copy_if_different  # which executes "cmake - E copy_if_different..."
        "${GOOGLETEST}/bld/${ARCH}/googlemock/gtest/$<$<CONFIG:Debug>:Debug>$<$<NOT:$<CONFIG:Debug>>:Release>/gtest.dll"      # <--this is in-file
        $<TARGET_FILE_DIR:main>                 # <--this is out-file path
    COMMAND ${CMAKE_COMMAND} -E copy_if_different  # which executes "cmake - E copy_if_different..."
        "${GOOGLETEST}/bld/${ARCH}/googlemock/gtest/$<$<CONFIG:Debug>:Debug>$<$<NOT:$<CONFIG:Debug>>:Release>/gtest_main.dll"      # <--this is in-file
        $<TARGET_FILE_DIR:main>)                 # <--this is out-file path
